package org.squabble.web.admin;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.squabble.domain.Article;
import org.squabble.service.ArticleService;

@Controller
@RequestMapping("/admin/news")
public class NewsCenterController {

	@Autowired
	ArticleService articleService;
	
	@RequestMapping(method=RequestMethod.GET)
	public String setupForm(@RequestParam(value="id", required=false) Long id, ModelMap model) {
		List<Article> articles = articleService.getArticles();
		model.addAttribute("articles", articles);
		return "admin.news";
	}
	
}
